/*
 * @Author: zhouwei wei.zhou@flip.fun
 * @Date: 2024-04-07 22:56:31
 * @LastEditors: zhouwei wei.zhou@flip.fun
 * @LastEditTime: 2024-04-07 23:00:18
 * @FilePath: /50/手撕系列/debounce.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 *
 * @param {Function} fn
 */
function debounce(fn, timeout = 1000) {
	let timer = null
	return function (...args) {
		if (timer) {
			clearTimeout(timer)
		}
		timer = setTimeout(() => {
			fn.call(this,...args)
			timer = null
		}, timeout)
	}
}
